package read1;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Pages {
	protected WebDriver driver = null;
	private String URL;
	static {System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\driver\\chromedriver_win32_2.29\\chromedriver.exe");}

	protected String getURL() {return "http://baidu.com";}
	protected String getURL(String partURL) {return getURL();}
	

	public Pages() {
		URL = getURL();
		initDriver(URL);
	}
	
	public Pages(String partURL) {
		URL = getURL(partURL);
		initDriver(URL);
	}

	private void initDriver(String pageURL) {
		driver = new ChromeDriver();
		driver.get(pageURL);
		driver.manage().window().maximize();
		sleep(3000);
	}

	public void sleep(int time) {
		try {
			Thread.sleep(time);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void close(){
		if (driver!=null) {
			driver.quit();
		}
	}
}
